package com.mingyizhudao.app.view.home.adapter;

import java.util.List;

import com.mingyizhudao.app.R;
import com.mingyizhudao.app.entity.HospitalEntity;
import com.mingyizhudao.app.view.home.bean.DeptToHospitalEntity;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class DeptToHospitalAdapter extends BaseAdapter{

	private Context mContext;
	private List<DeptToHospitalEntity> hospitalList;
	private LayoutInflater inflater;
	public DeptToHospitalAdapter(Context context,List<DeptToHospitalEntity> hospitalList) {
		this.mContext = context;
		this.hospitalList = hospitalList;
		this.inflater = LayoutInflater.from(mContext);
	}

	@Override
	public int getCount() {
		return hospitalList==null?0:hospitalList.size();
	}

	@Override
	public Object getItem(int arg0) {
		return hospitalList.get(arg0);
	}

	@Override
	public long getItemId(int arg0) {
		return arg0;
	}

	@Override
	public View getView(final int position, View convertView, ViewGroup parent) {
		ViewHolder holder;
		if(convertView == null){
			convertView = inflater.inflate(R.layout.lv_item_dept_to_hospital, parent, false);
			holder = new ViewHolder();
			holder.tv_name = (TextView) convertView.findViewById(R.id.tv_name);
			holder.tv_class = (TextView) convertView.findViewById(R.id.tv_class);
			convertView.setTag(holder);
		}else{
			holder = (ViewHolder)convertView.getTag();
		}
		holder.tv_name.setText( hospitalList.get(position).getName() );
		holder.tv_class.setText( "医院实际科室名称："+hospitalList.get(position).getHp_dept_name() );
		
		return convertView;
	}

	public final class ViewHolder{
		public TextView	tv_name = null;
		public TextView	tv_class = null;
	}

}
